﻿@inherits BaseComponent

<div class="ws-chart">
    <div class="ant-card ant-card-bordered" style="height:100%;">
        <div class="ant-card-head">
            <div class="ant-card-head-wrapper">
                <div class="ant-card-head-title">@Title</div>
            </div>
        </div>
        <div class="ant-card-body">
            <KChart @ref="chart" Id="chart" />
        </div>
    </div>
</div>

@code {
    private KChart chart;

    [Parameter] public string Title { get; set; }

    public async Task SetOptionAsync(ChartCardOption option)
    {
        var info = option?.Charts?.FirstOrDefault();
        if (info?.Type == "Line")
            await chart?.ShowLineAsync(info?.Title, info?.Datas);
        else if (info?.Type == "Bar")
            await chart?.ShowBarAsync(info?.Title, info?.Datas);
        else if (info?.Type == "Pie")
            await chart?.ShowPieAsync(info?.Title, info?.Datas);
    }
}